package cn.edu.scau.info.hhb.jReflashDns;

import java.util.HashMap;

import org.apache.commons.codec.binary.Base64;

public class DDNSoray {
	
		private final String localIP;
		private final String domain;
		private final String user;
		private final String passwd;
		
		
		
		public static final String url="http://ddns.oray.com/ph/update";
		
		public DDNSoray(String localIP, String user, String passwd,String domain){
			this.localIP=localIP;
			this.user=user;
			this.passwd=passwd;
			this.domain=domain;
		}
		
		
		public String update(){
			return update(localIP);
		}
		
		public String update(String ip){
			HashMap<String,String> map = new HashMap<String,String>();
			String base64 = new String(Base64.encodeBase64((user+":"+passwd).getBytes()));
			map.put("Authorization", "Basic "+base64);
			return HttpUtil.get(url+"?hostname="+domain+"&myip="+ip, map);
		}
}
